package net.crisps.cloud.utils.robot_util.service.default_config;

import lombok.extern.slf4j.Slf4j;
import net.crisps.cloud.utils.robot_util.service.WechatRobotConfigService;
import net.crisps.cloud.utils.robot_util.vo.WeChatRobotConfigVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.stereotype.Component;

import java.util.Collection;
import java.util.List;

/**
 * 自定义此类方法，继承此类 重写其方法
 *
 * @author tangchuan
 * @date 2023/11/17 15:24
 */
@Slf4j
@Component
@ConditionalOnMissingBean(WechatRobotConfigService.class)
public class DefaultWechatRobotConfigService extends AbstractWechatRobotConfigService {

    @Autowired(required = false)
    private DefaultExceptionIgnoreService exceptionIgnoreService;

    @Autowired(required = false)
    DefaultTreeBookConfigService weChatRobotTreeBookConfigService;

    private Collection<Class<? extends Exception>> getDefaultExceptionIgnoreList() {
        if (exceptionIgnoreService == null) return null;
        return exceptionIgnoreService.getDefaultExceptionIgnoreList();
    }

    private WeChatRobotConfigVo getDefaultWeChatRobotConfig() {
        if (weChatRobotTreeBookConfigService == null) return null;
        return weChatRobotTreeBookConfigService.getDefaultConfig();
    }

    /**
     * 默认忽略异常列表
     *
     * @return {@link List}<{@link Class}<{@link ?} {@link extends} {@link Exception}>>
     */
    @Override
    public Collection<Class<? extends Exception>> getIgnoreException() {
        return getDefaultExceptionIgnoreList();
    }

    /**
     * 字典机器人配置
     */
    @Override
    public WeChatRobotConfigVo getWeChatRobotConfigVo() {
        return getDefaultWeChatRobotConfig();
    }


}
